home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-03-30 | 2.6 KB | 75 lines | [TEXT/GEOL] |
- Item 0239174 30-March-90 11:31PST
-
- From: D5369 Mgmt Sys Des, Chuck McMath,PRT
-
- To: MACAPP.TECH$ MacApp Technical
-
- Sub: THINK Pascal Conversion
-
- Folks:
-
- I received THINK Pascal 3.0 last weekend, and have spent a few days converting
- a large program to it from MPW. The conversion went smoothly for the most
- part, thanks to the good instructions in the manual. However, I did run into
- one 'gotcha'. Take heed:
-
- You may be aware that there is more than one way to indicate conditional
- complilation in MacApp:
-
- {$IFC qDebug}
- Writeln('Hey, I am debugging this baby.');
- {$ENDC}
-
- is the 'traditional' way. With MacApp 2.0ß9, you can use another technique (I
- first saw this mentioned by Keith Rollin in FrameWorks Vol. 3, No. 3):
-
- IF qDebug THEN
- Writeln('Hey, I am debugging this baby.');
-
- The second case works because UMacAppUtilities declares a set of variables
- named identically to the debug compile-time switches (look it up if you don't
- believe me!). The MPW compiler does not emit code for the second case if
- qDebug is FALSE, because UMacAppUtilities has been compiled and the variable is
- set.
-
- The problem is that the THINK Pascal compiler doesn't make the same decision --
- the value of the MacApp variable qDebug (NOT the compile time switch) is
- unknown when you compile your unit. Therefore, the compiler has to compile the
- Writeln in the second case - it just never gets executed. So what, you say?
- Well, if you reference a debugging routine like ReadInteger (which I do) and
- try to build a non-MacApp Debugger project (like I did) you will get link
- errors (you get the idea). My particular example:
-
- IF qDebug THEN
- spd := ReadInteger('Enter idle speed (in ticks) :');
-
- ReadInteger (MacApp Condensed Reference, p.73) obviously doesn't exist in the
- non-MacApp debugger instance, so the Linker could not find it. The bottom line
- is:
-
- to ensure compatibility, use the compile-time switches in your code
-
-
- Item 2: THINK Pascal also doesn't like VAR declarations of the form:
-
- CONST
- aNumber = 10;
- VAR
- anArray: ARRAY [0..aNumber-1] OF INTEGER; <-- choke here
-
- Rather use this style:
-
- CONST
- aNumber = 10;
- aNumberMinusOne = aNumber - 1;
- VAR
- anArray: ARRAY [0..aNumberMinusOne] OF INTEGER;
-
- Other than that, the conversion was pretty smooth sailing. Now if my program
- only worked like it was supposed to...
-
- Whew!
-
- chuck mcmath
-
-